package com.yjhb.android.sbz.mvp.new_user_task_list;

import com.yjhb.android.sbz.entity.TaskInfo;
import com.yjhb.android.sbz.http.HttpObserver;
import com.yjhb.android.sbz.http.HttpTool;
import com.yjhb.android.sbz.mvp.ConventionPresenter;

import java.util.List;

/**
 * 创建者 zx
 * 创建时间 2020/12/21 10:09
 */
public class NewUserTaskListPresenter extends ConventionPresenter<NewUserTaskListView> {
    private final String TAG = "NewUserTaskListPresenter";

    @Override
    protected void onDestroy() {

    }

    public NewUserTaskListPresenter(NewUserTaskListView newUserTaskListView) {
        super(newUserTaskListView);
    }


    public void getList(int size, final int current) {
        HttpTool.request(model.hallTaskList(1, 1, null, 1, size, current),
                new HttpObserver<List<TaskInfo>>() {
                    @Override
                    public void onResult(List<TaskInfo> data) {
                        if (view != null) {
                            if (current == 1) {
                                view.onRefresh(data);
                            } else {
                                view.onLoad(data);
                            }
                        }
                    }

                    @Override
                    public void onError(int code, String msg) {
                        if (view!=null){
                            view.onFailure(code, msg);
                        }
                    }
                });
    }

}
